package org.longs.converter;

import lombok.Getter;
import lombok.Setter;
import org.longs.bean.ImageFile;
import org.longs.stream.LittleAccessFile;

import java.io.FileOutputStream;
import java.io.IOException;

public class WavConverter extends BaseConverter {
    @Setter
    @Getter
    private String name;

    @Setter
    @Getter
    private byte[] bytes;
    public WavConverter(LittleAccessFile randomAccessFile) {
        super(randomAccessFile);
    }


    @Override
    public String getFlag() {
        return "RIFF";
    }

    @Override
    public void analysisBody(LittleAccessFile randomAccessFile) throws IOException {
        bytes = analysisSpaces();
    }
    public byte[] analysisSpaces() throws IOException {
        LittleAccessFile is = getRandomAccessFile();
        is.seek(getOffset());
        byte[] bytes = new byte[Math.toIntExact(getTotal())];
        is.readFully(bytes);
        return bytes;
    }
}
